import {ref} from "vue";
import {mainStore} from "../store/store.ts";

export function useMainLogin() {
    const store = mainStore()
    // const {loginStatus} = storeToRefs(store)
    const showInfomation = ref<boolean>()
    const userHeaderInfo = ref()
    const {getter_loginStatus} = store
    const dialogVisible = ref(false);

    showInfomation.value = getter_loginStatus()

    const login = () => {
        dialogVisible.value = false
        showInfomation.value = getter_loginStatus()
        // userHeaderInfo.value.userName = mainStore().userName
        // userHeaderInfo.value.changeUserName(mainStore().userName)
    }
    const handleClose = (done: () => void) => {
        done()
    }

    const pdLogin = () => {
        if (!showInfomation.value) {
            dialogVisible.value = true
        }
    }
    const exit = () => {
        // loginStatus.value = false;
        const {setter_loginStatus} = store
        setter_loginStatus(false)
        login();
    };

    return {
        showInfomation, dialogVisible, login, handleClose, pdLogin, exit, userHeaderInfo
    }
}
